public class SequentialList {
    private final int initapacity = 10;
    public int[] date;
    public int size;
    public int capicity;
    public SequentialList(){
        date = new int[initapacity];
        capicity = initapacity;
        size = 0;
    }

    public void updatecapacity(int newcapacity){
        int[] newdate = new int[newcapacity];
        for(int i = 0; i < size; i++){
            newdate[i] = date[i];
            capicity = newcapacity;
            date = newdate;
        }
    }
    public void creatList(int[] a){
        size = 0;
        for(int i = 0; i < a.length; i++){
            if(size == capicity){
                updatecapacity(2*size);
                date[size] = a[i];
                size++;
            }
        }
    }
    public int size() {
        return size;
    }
    public void setSize(int nlen){
        if(nlen < 0 || nlen > size){
            throw new IllegalArgumentException("设置长度不在有效范围内")l
        }
        size = nlen;
    }

    public void Add(int e){
        if(size == capicity){
            updatecapacity(2*size);
            date[size] = e;
            size++;
        }
    }
    public int GetElem(int i){
        if(i < 0 || i > size - 1){
            throw new IllegalArgumentException("所查的位置不在有效位置");
        }
        return date[i];
    }
    
}
